home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir27 / calctool.zip / CALCTOOL.H < prev    next >
C/C++ Source or Header  |  1992-09-10  |  7KB  |  182 lines

  1.  
  2. /*  @(#)calctool.h 1.10 89/11/06
  3.  *
  4.  *  Contains all the global definitions used by calctool.
  5.  *
  6.  *  Copyright (c) Rich Burridge.
  7.  *                Sun Microsystems, Australia - All rights reserved.
  8.  *
  9.  *  Permission is given to distribute these sources, as long as the
  10.  *  copyright messages are not removed, and no monies are exchanged.
  11.  *
  12.  *  No responsibility is taken for any errors or inaccuracies inherent
  13.  *  either to the comments or the code of this program, but if
  14.  *  reported to me then an attempt will be made to fix them.
  15.  */
  16.  
  17. /* char *getenv(), *getwd(), *sprintf() ; */
  18. char *getenv(), *getwd() ;
  19.  
  20. #define  CLOSE          (void) close      /* To make lint happy. */
  21. #define  FCLOSE         (void) fclose
  22. #define  FFLUSH         (void) fflush
  23. #define  FGETS          (void) fgets
  24. #define  FPRINTF        (void) fprintf
  25. #define  IOCTL          (void) ioctl
  26. #define  PUTC           (void) putc
  27. #define  READ           (void) read
  28. #define  SELECT         (void) select
  29. #define  SIGNAL         (void) signal
  30. #define  SPRINTF        (void) sprintf
  31. #define  SSCANF         (void) sscanf
  32. #define  STRCAT         (void) strcat
  33. #define  STRCPY         (void) strcpy
  34. #define  STRNCAT        (void) strncat
  35. #define  STRNCPY        (void) strncpy
  36. #define  WRITE          (void) write
  37.  
  38. /* Various pseudo events used by the calctool program. */
  39. #define  CFRAME_REPAINT   100    /* Main frame needs repainting. */
  40. #define  RFRAME_REPAINT   101    /* Register frame needs repainting. */
  41. #define  ENTER_WINDOW     102    /* Mouse has enter calctool window. */
  42. #define  EXIT_WINDOW      103    /* Mouse has exited calctool window. */ 
  43. #define  KEYBOARD         104    /* Keyboard character was pressed. */
  44. #define  LEFT_DOWN        105    /* Left mouse button was depressed. */
  45. #define  LEFT_UP          106    /* Left mouse button was debounced. */
  46. #define  MIDDLE_DOWN      107    /* Middle mouse button was depressed. */
  47. #define  MIDDLE_UP        108    /* Middle mouse button was debounced. */
  48. #define  RIGHT_DOWN       109    /* Right mouse button was depressed. */
  49. #define  RIGHT_UP         110    /* Right mouse button was debounced. */
  50. #define  TAKE_FROM_SHELF  111    /* PUT function key was pressed. */
  51. #define  PUT_ON_SHELF     112    /* GET function key was pressed. */
  52. #define  DIED             113    /* Calctool window has been destroyed. */
  53. #define  LASTEVENTPLUSONE 114    /* Not one of the above. */
  54.  
  55. #define  HELPCURSOR     0      /* Cursor types. */
  56. #define  MAINCURSOR     1
  57.  
  58. enum base_type { BIN, OCT, DEC, HEX } ;      /* Base definitions. */
  59.  
  60. enum but_state { NORMAL, INVERTED } ;        /* Calculator button states. */
  61.  
  62. enum can_type { KEYCANVAS, REGCANVAS, PANELCANVAS } ;  /* Canvas types. */
  63.  
  64. enum font_type { SFONT, NFONT, BFONT } ;     /* Text font definitions. */
  65.  
  66. /* Graphics supported. */
  67. enum gr_type  { MGR, NEWS, SVIEW, TTY, X11, XVIEW } ;
  68.  
  69. /* Pseudo panel items. */
  70. enum item_type { BASEITEM, DISPLAYITEM, TTYPEITEM, NUMITEM,
  71.                  HYPITEM,  INVITEM,     OPITEM } ;
  72.  
  73. /* Popup menu types. Used with some of the graphics versions. */
  74. enum menu_type {
  75.        M_ACC,    M_CON,   M_EXCH,   M_FUN,
  76.        M_LSHIFT, M_RCL,   M_RSHIFT, M_STO
  77. } ;
  78.  
  79. enum num_type { FIX, SCI } ;                 /* Number display mode. */
  80.  
  81. enum op_type { OP_SET, OP_CLEAR, OP_NOP } ;  /* Operation item settings. */
  82.  
  83. enum trig_type { DEG, GRAD, RAD } ;          /* Trigonometric types. */
  84.  
  85. /*  Mathematical constants used by the routines in functions.c
  86.  *  These should be declared in math.h, but just in case....
  87.  */
  88.  
  89. #ifndef  HUGE
  90. #define  HUGE            1.701411733192644270e38
  91. #endif /*HUGE*/
  92.  
  93. #ifndef  LN10
  94. #define  LN10            2.30258509299404568402
  95. #endif /*LN10*/
  96.  
  97. #ifndef  PI
  98. #define  PI              3.14159265358979323846
  99. #endif /*PI*/
  100.  
  101. #define  BBORDER        10     /* No of pixels in border. */
  102. #define  BCOLS          6      /* No of columns of buttons. */
  103. #define  BGAP           5      /* No of pixels between buttons. */
  104. #define  BHEIGHT        52     /* Number of pixels for height. */
  105. #define  BROWS          6      /* No of rows of buttons. */
  106. #define  BWIDTH         44     /* No of pixels for width. */
  107.  
  108. #define  CCTRL(n)       n - 96     /* Generate control character value. */
  109. #define  DISPLAY        30         /* Calculators numerical display. */
  110.  
  111. #define  EQUAL          !strcmp    /* For character comparisons. */
  112. #define  EXTRA          5          /* Extra useful character definitions. */
  113.  
  114. #ifndef  HELPNAME
  115. #define  HELPNAME       "calctool.help"
  116. #endif /*HELPNAME*/
  117.  
  118. #define  ICONHEIGHT     64         /* Height of calctool icon. */
  119. #define  ICONWIDTH      42         /* Width of calctool icon. */
  120. #define  INC            argc-- ; argv++ ;
  121. #define  MAX_DIGITS     32         /* Maximum displayable number of digits. */
  122. #define  MAXITEMS       7          /* Maximum number of panel items. */
  123.  
  124. #ifndef  MAXLINE
  125. #define  MAXLINE        256        /* Length of character strings. */
  126. #endif /*MAXLINE*/
  127.  
  128. #define  MAXMENUS       8          /* Maximum number of popup menus. */
  129.  
  130. #ifndef  MAXPATHLEN
  131. #define  MAXPATHLEN     1024       /* Longest possible path length. */
  132. #endif /*MAXPATHLEN*/
  133.  
  134. #define  MAXREGS        10         /* Maximum number of memory registers. */
  135. #define  MAXVKEYS       7          /* Number of valid keys after an error. */
  136.  
  137. #ifndef  MIN
  138. #define  MIN(x,y)       ((x) < (y) ? (x) : (y))
  139. #endif /*MIN*/
  140.  
  141. #ifndef  NEWSFILE
  142. #define  NEWSFILE       "calctool.ps"
  143. #endif /*NEWSFILE*/
  144.  
  145. #define  NOBUTTONS      BROWS * BCOLS
  146.  
  147. #ifdef   NOINDEX
  148. #define  index          strchr
  149. #endif /*NOINDEX*/
  150.  
  151. #ifndef  RCNAME
  152. #define  RCNAME         ".calctoolrc"
  153. #endif /*RCNAME*/
  154.  
  155. #ifndef  NO_4_3SIGNAL
  156. #define  SIGRET         void
  157. #else
  158. #define  SIGRET         int
  159. #endif /*NO_4_3SIGNAL*/
  160.  
  161. #define  THEIGHT        (BROWS*BHEIGHT) + ((BROWS-1) * BGAP) + (2*BBORDER)
  162. #define  TITEMS         NOBUTTONS*2 + EXTRA    /* Total definitions. */
  163. #define  TWIDTH         (BCOLS*BWIDTH) + ((BCOLS-1) * BGAP) + (2*BBORDER)
  164.  
  165. typedef  unsigned long  BOOLEAN ;
  166.  
  167. struct iteminfo                  /* Panel item information record. */
  168.   {
  169.     enum font_type font ;        /* Font type for this panel item. */
  170.     int x ;                      /* X position of item. */
  171.     int y ;                      /* Y position of item. */
  172.     char text[60] ;              /* Text string associated with this item. */
  173.   } ;
  174.  
  175. struct button {
  176.          char *str ;             /* Button display string. */
  177.          char value ;            /* Unique button keyboard equivalent. */
  178.          enum op_type opdisp ;   /* Display operation code during operation. */
  179.          char color ;            /* Color of button portion. */
  180.          int  (*func)() ;        /* Function to obey on button press. */
  181. } ;
  182.